package com.jackiechancinema.ssm.controller;

import com.jackiechancinema.ssm.bo.DrillBo;
import com.jackiechancinema.ssm.entity.Drills;
import com.jackiechancinema.ssm.service.Inte.DreamService;
import com.jackiechancinema.ssm.service.Inte.DrillService;
import com.jackiechancinema.ssm.vo.PageVo;
import com.jackiechancinema.ssm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/drill")
public class DrillController {
    @Autowired
    private DrillService drillService;

//    //查询所有
//    @RequestMapping("/find")
//    public PageVo<Drills> find(int page, int limit){
//        PageInfo<Drills> all = drillService.findAll(page,limit);
//        PageVo<Drills> pageVo = new PageVo<Drills>(SystemContant.PAGE_R,"OK",all.getTotal(),all.getList());
//        return pageVo;
//    }

    @RequestMapping("/find")
    public PageVo<Drills> find(DrillBo bo){


//        PageInfo<Movices> all = moviceService.findAll(page,limit);
//        PageVo<Movices> pageVo = new PageVo<Movices>(SystemContant.PAGE_R,"OK",all.getTotal(),all.getList());
//        return pageVo;
        return drillService.findAllV2(bo);
    }

    //添加
    @RequestMapping("/add")
    public R DrillAdd(Drills drills){
        System.out.println(drills);
        return drillService.DrillAdd(drills);
    }

    //修改
    @RequestMapping("/update")
    public R DrillUpdate(Drills drills){
//        Movices movices1 = new Movices(1,"123","123","123");
        return drillService.DrillUpdate(drills);
    }

    //根据ID删除
    @RequestMapping("/del")
    public R DrillDel(int id){
        return drillService.DrillDel(id);
    }
}
